﻿namespace DCHealthCheck.MvcWeb.Classes {

    #region Usings
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web; 
    #endregion

    public class WebErrorInfoFactory {

        public WebErrorInfo GetWebErrorInfo() {
            WebErrorInfo pageError = null;
            if ((HttpContext.Current != null) && (HttpContext.Current.Session != null) && (HttpContext.Current.Session["errorInfo"] != null)) {
                pageError = HttpContext.Current.Session["errorInfo"] as WebErrorInfo;
            }
            // for the Simple Injector tests only
            if (pageError == null) {
                pageError = new WebErrorInfo(new ApplicationException("Fake Exception"), "FakeController", "FakeAction");
            }
            return pageError;
        }
    }
}